﻿<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="framework.core.SrvContext"%>
<%@page import="system.LoginContext"%>
<%@ include file="../../common.jsp" %>
<%@ taglib uri="/page.util.gs.hitrust.com/taglibs/page" prefix="page"%>



<html>
<head>
<title>智能补货</title>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=root%>/css/caigouxitong.css" type=text/css rel=stylesheet>
<SCRIPT language="JavaScript" src="<%=root%>/js/common.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/calendar.js"></SCRIPT>
<SCRIPT language="JavaScript" src="<%=root%>/js/string.js"></SCRIPT>

<%
ArrayList ary = (ArrayList)request.getAttribute("organdaddr");
String showMinZero = (String)request.getAttribute("showMinZero");
int totalRecords = 0;
%>

<script>
	var counter;
	<%
		//在此作出成功提示
		if(request.getAttribute("SUCCESSMSG") != null)
			out.print("alert('"+request.getAttribute("SUCCESSMSG")+"');");
	%>
	
	
	
	var flag=false;

	function process(val){
		if(flag&&val=='Q'){
			alert("正在查询，请稍候！");
			return false;
		}
		if(val == 'Q'){
			orderrauditform.action = "<%=response.encodeURL(root+"/A102002.do")%>";
    		orderrauditform.submit();		
    		flag=true;
		}else if(val == 'T'){
			createOrder();
		}
	}
	function cls(){
		document.all.orderDept.selectedIndex = 0;
		document.all.showMinZero.selectedIndex = 0;
		document.all.concentricityId.value = "";
		document.all.manufInfo.value = "";
	}
	function createOrder(){
    var checks=document.getElementsByName("ids");
    var count=0;
    var array=new Array();
    for(var a=0;a<checks.length;a++){
        if(checks[a].checked){
            array[count]=checks[a].value;
            count++;
        }
    }
    if(count==0){
        alert("请选择生成订单产品！");
        return false;
    }
    if(count>10){
        alert("生成订单产品不能超过10个!");
        return false;
    }
    for(var i=0;i<array.length;i++){
        var val=array[i].split("@@")[1];
        for(var j=i+1;j<array.length;j++){
            var val2=array[j].split("@@")[1];
            if(val!=val2){
                alert("请选择同一仓库生成订单");
                return false;
            }
        }
    }
    
    var url = "<%=response.encodeURL(root+"/A100110.do")%>?val="+array;
    window.open(url,null," center=Yes, help=No, resizable=Yes, status=Yes, width=900px, height=600px, scrollbars=yes");
}
</script>
</head>
<%
	GSOrderAuditQueryVO oaqVO = (GSOrderAuditQueryVO)session.getAttribute("QUERYCONDITION");
	ResultProcess tOrder = (ResultProcess)request.getAttribute("orderlist");
	ArrayList tList = new ArrayList();
	String [] tStr = null;
%>
<body BGCOLOR="#f5f5f5"	text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" >

<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td height="20"> 
      <table width="100%" border="0" cellspacing="0" cellpadding="1">
        <tr height="20">
          <td height="20" width="1" class="mtxt_black">&nbsp;</td>
          <td height="30" width="758" class="mtxt_black">智能补货</td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td class="bg_line" height="2"></td>
  </tr>
</table>

<br>

<%String warehouseCode = oaqVO==null?"":oaqVO.deptId; %>

<form name="orderrauditform" method="get" >
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
	<tr> 
		<td> 
			<table class=bg_table id=tableId	cellspacing=1 cellpadding=0 style="padding-left:5;padding-right:5" width=100% align=center border=0>
				<TR height=20>
                    <TD class="bg_column" align=center>所属仓库</TD>
                    <TD align=left class="bg_row_odd">
                        <select id='orderDept' name='orderDept'>
                            <option value="<%=LoginContext.get(new SrvContext(request,response)).getLoginWarehouseCode() %>">---全部---</option>
                            <%
                              if(ary!=null&&ary.size()>0){
                                 for(int i=0;i<ary.size();i++){ 
                                     GSWareHouseBean tmp=(GSWareHouseBean)ary.get(i);%>
                                    <%if(tmp.getCode().equals(warehouseCode)){ %>
                                        <option value="<%=tmp.getCode() %>" selected><%=tmp.getName() %></option>
                                    <%}else{ %>
                                    <option value="<%=tmp.getCode() %>"><%=tmp.getName() %></option>
                            <%}}} %>                                    
                        </select>
                    </TD>
                    <TD class="bg_column" align=center>集中编码</TD>
                    <TD align=left class="bg_row_odd">
                    <input type="text" name="concentricityId" maxlength="20" value="<%=oaqVO==null?"":oaqVO.concentricityId%>">
                    </TD>	
				</TR>									
				<TR height=20>
					<TD class="bg_column" align=center>产品信息</TD>
					<TD align=left class="bg_row_odd" colspan="3">
					<input type="text" name="manufInfo" maxlength="200" value="<%=oaqVO==null?"":oaqVO.manufInfo %>">（<FONT color="#ff0033">对产品名称、型号、规格、品牌、生产厂商、附加属性等关键字的模糊查询</FONT>）&nbsp;
					</TD>
				</TR>		
				
				<TR height=20>
			  
                    <TD class="bg_column" align=center>是否显示安全库存为0的数据</TD>
                    <TD align=left class="bg_row_odd"  colspan="3">
                        <select id='showMinZero' name='showMinZero'>
                        <%if(showMinZero!=null&&"Y".equals(showMinZero)) {%>
                            <option value="" >是</option>
                            <option value="Y" selected="selected">否</option>    
                         <%}else{ %>        
                            <option value="" selected="selected">是</option>
                            <option value="Y">否</option>      
                         <%} %>
                        </select>
                    </TD>		
				</TR>										
                	
			</table>
		</td>
	</tr>
</table>
<%
if(tOrder != null) {
  if(request.getAttribute("totalRecords")!=null){
      totalRecords=Integer.parseInt((String)request.getAttribute("totalRecords"));
  }
  int defaultPageSize =10;
  if(request.getAttribute("pageSize")!=null){
      defaultPageSize=Integer.parseInt((String)request.getAttribute("pageSize"));
  }
%>          
<page:pager total='<%=totalRecords%>' defaultPageSize='<%=defaultPageSize%>'>
</page:pager>
<%} %>
</form>
    <p align="center">  
		<input type="button" width="58" class="kuang" height="24" value="查询" onclick="process('Q')"/>&nbsp;
		<input type="button" width="58" class="kuang" height="24" value="清空" onclick="cls()"/>
    </p>
<%
	
	if(tOrder != null){
%>
	<center>
    <table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr>
			<td>
            <form name ='pager'>
			<input type="hidden" name='confirmorreject'>
            <input type='hidden' name='auditcontent' >
            	<table class=bg_table id=tableId	cellspacing=1 cellpadding=2 width=100% align=center border=0>
                    <tbody> 
                    <tr class="bg_column" height=20> 
                    	<td></td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">仓库</div>
						</td>								
                        <td class=top align=center> 
                        <div align="center" class="txt_content">集中编码</div>
						</td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">产品名称</div>
						</td>
						<td class=top align=center> 
                        <div align="center" class="txt_content">供应商</div>
						</td>	
                        <td class=top align=center> 
                        <div align="center" class="txt_content">规格</div>
						</td>									
						<td class=top align=center> 
                        <div align="center" class="txt_content">型号</div>
						</td>									
						<td class=top align=center> 
                        <div align="center" class="txt_content">品牌</div>
						</td>
						<td class=top align=center> 
                        <div align="center" class="txt_content">价格（元）</div>
						</td>	
                        <td class=top align=center> 
                        <div align="center" class="txt_content">单位</div>
                        </td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">库存数量</div>
						</td>		
						<td class=top align=center> 
                        <div align="center" class="txt_content">安全库存</div>
						</td>	
						<td class=top align=center> 
                        <div align="center" class="txt_content">最大库存</div>
						</td>		
                        <td class=top align=center> 
                        <div align="center" class="txt_content">建议补货数量</div>
                        </td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">前三月平均出库数量</div>
                        </td>
                        <td class=top align=center> 
                        <div align="center" class="txt_content">结算模式</div>
                        </td>
					</tr>
					<%tList=tOrder.getAllRecoreds();
						if(tList != null && tList.size() > 0){
						for(int i=0; i<tList.size(); i++){
							tStr=(String[])tList.get(i);
							String tTempStr="";
							if(i%2==0){
								tTempStr="class=\"bg_row_odd\"";
							}else {
								tTempStr="class=\"bg_row_even\"";
							}
							int size = 0;
					%>
							<tr <%=tTempStr%> height=20>
								<td class=top align=center > 
									<div align="center" class="txt_content">
									<input type="checkbox" name="ids" value="<%=tStr[0]+"@@"+tStr[13]%>">
									</div>
								</td>			
								<td class=top align=center  nowrap> 								
									<div align="center" class="txt_content">
									<%=tStr[1] %>
									</div>
								</td>	
								<td class=top align=center > 
									<div align="center" class="txt_content">
									<%=tStr[2] %>
									</div>
								</td>	
								<td class=top align=center > 								
									<div align="center" class="txt_content">
									<a href="<%=response.encodeURL(root+"/A100306.do")%>?concentricityId=<%=tStr[2]%>" target=_blank><%=tStr[3]%></a>
									</div>
								</td>	
								<td class=top align=center > 								
									<div align="center" class="txt_content">
									<%=tStr[8] %>
									</div>
								</td>	
								<td class=top align=center > 								
									<div align="center" class="txt_content">
									<%=tStr[5] %>
									</div>
								</td>	
								<td class=top align=center nowrap> 
									<div align="center" class="txt_content">
									<%=tStr[6] %>
									</div>
								</td>
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[7] %>
									</div>
								</td>
                                <td class=top align=center> 
                                    <div align="center" class="txt_content">
                                    <%=tStr[9]%>
                                    </div>
                                </td>
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[4]%>
									</div>
								</td>								
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[10]%>
									</div>
								</td>		
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[15]%>
									</div>
								</td>	
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[16]%>
									</div>
								</td>									
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[14]%>
									</div>
								</td>	
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[11]%>
									</div>
								</td>																
								<td class=top align=center> 
									<div align="center" class="txt_content">
									<%=tStr[12]%>
									</div>
								</td>						
																																															
							</tr> 
						
					<%
							}
					%>
						  <tr class="bg_column" height=20>
						    <td width="960" height="16" colspan="16" align="right">
									<!--导航条-->
						    		<page:navigator type='text' queryForm='orderrauditform'/>
						    </td>
						  
				    <%
						}else{
					%>
							<font color="red">没有符合条件的申购单信息,请重新输入查询条件</font>
					<%
						}
					%>
					</tbody>
				</table>
				</form>					  
			</td>
		</tr>
	</table>
	</center>
	<p align="center">  
	    <input type="button"  value="　　导出EXCEL　　"  class="kuang"    onclick="doExcel();return false;"/>&nbsp;
    	<input type="button" class="kuang" name="提交" value="补货申请" onclick="process('T')"/>
    </p>
	
<%		
	}
%>
<script language=javascript>

function doExcel(){
    <%if (totalRecords> 20000) {%>
        alert("导出EXCEL产品数量不能超过20000条！");
        return false;
    <%} else {%>
        window.location.href="<%=root%>/GSproductStorageDown";
    <%}%>
}
</script>
</body>
</html>